<template>
	<view class="content">
		<!-- village -->

		<!-- 搜索框 -->
		<view class="header1">
			<view class="down">
				<view class="flex1 down-item" :class="type?'upColor':''" @tap="downType()">
					<text>{{checkEquipment.label||'设备类型'}}</text>
					<u-icon class="ml10 trion1" :class="type?'rotote':''" name="arrow-down-fill" color="#FFFFFF"
						size="20"></u-icon>
				</view>
				<view class="flex1 down-item" :class="time?'upColor':''" @tap="downTime()">
					<text>{{classifyObj.name||'设备分类'}}</text>
					<u-icon class="ml10 trion1" :class="time?'rotote':''" name="arrow-down-fill" color="#FFFFFF"
						size="20"></u-icon>
				</view>
				<view class="flex1 down-item" :class="screen?'upColor':''" @tap="downStatus()">
					<text>{{statusObj.label||'检查状态'}}</text>
					<u-icon class="ml10 trion1" :class="screen?'rotote':''" name="arrow-down-fill" color="#FFFFFF"
						size="20"></u-icon>
				</view>
				<!-- <view class="flex1 ipt">
					<u-icon class="ipt-icon" name="search" color="#999999" size="30" @tap="search"></u-icon>
					<input type="text" v-model="searchIpt" placeholder="搜索" confirm-type="search" @confirm="search" />
				</view> -->
			</view>
			<!-- 下拉菜单 -->
			<template>
				<view class="mask" @tap="mask" v-if="type">
					<scroll-view scroll-y="true" :class="type?'h300':''" class="scroll">
						<template v-for="i,index in options">
							<view class="scroll-item" @tap="choose(i)" :key="index">{{i.label}}</view>
						</template>
					</scroll-view>
				</view>
				<view class="mask" @tap="mask" v-if="time">
					<scroll-view scroll-y="true" :class="time?'h300':''" class="scroll">
						<template v-for="i,index in statusList">
							<view class="scroll-item" @tap="choose_status(i)" :key="index">{{i.name}}</view>
						</template>
					</scroll-view>
				</view>
				<view class="mask" @tap="mask" v-if="screen">
					<scroll-view scroll-y="true" :class="screen?'h300':''" class="scroll">
						<template v-for="i,index in screenList">
							<view class="scroll-item" @tap="choose_screen(i)" :key="index">{{i.label}}</view>
						</template>
					</scroll-view>
				</view>
			</template>
			<!-- <view class="ipt-box">
				<input v-model="searchIpt" type="text" placeholder="请输入您要搜索的内容"
					placeholder-class="plac-class" style="flex: 1;" />
				<image src="/static/search1.png" @tap="searNum"></image>
			</view>
			<view class="header1-right" @tap="clousText">
				<easy-select class="easySelect" style="width:360rpx;height:100%;font-size: 28rpx;color: #fff;"
					:options="options" ref="easySelect" size="medium" :value="checkEquipment.label"
					@selectOne="selectOne">
				</easy-select>
			</view> -->
		</view>
		<!-- 列表 -->
		<template>
			<view class="village-box" v-for="item,index in villageList" :key="index">
				<view class="village-item" @tap="villages(item.village_id)">
					<image class="flag" src="/static/status/s1.png" v-if="item.status==1"></image>
					<image class="flag" src="/static/status/s2.png" v-if="item.status==2"></image>
					<image class="flag" src="/static/status/s3.png" v-if="item.status==3"></image>
					<image class="flag" src="/static/status/s7.png" v-if="item.status==4"></image>
					<image class="flag" src="/static/status/s5.png" v-if="item.status==5"></image>
					<image class="flag" src="/static/status/s6.png" v-if="item.status==6"></image>

					<view class="village-item-left">
						<view class="adress-box">
							<view class="shuxian"></view>
							<view class="adress">{{item.address}}</view>
							<!-- <view class="navMap" @tap="navMap">导航</view> -->
						</view>
						<view class="time">
							<image src="/static/clock.png" mode=""></image>
							<span>{{item.create_time_text}}-{{item.close_time_text}}</span>
						</view>
					</view>
					<view class="village-item-right">
						<view class="huhao">{{item.reclassify_text}}</view>
						<text class="count">{{item.count}}</text>
						<!-- <image src="/static/zhankai.png" mode=""></image> -->
					</view>
				</view>
			</view>
		</template>
		<!-- <template>
			<view class="list" v-for="item,index in villageList" :key="index">
				<view class="left">
					<view class="top">
						<view class="img"></view>
						<view class="title">{{item.type}}</view>
					</view>

					<view class="bottom">
						<image src="/static/pagesB/time.png" mode=""></image>
						<view class="time">{{item.create_time_text}}</view>
					</view>
				</view>
				<view class="right" @tap="look">检查</view>
			</view>
		</template> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchIpt: '',
				username: '',
				password: '',
				// array: ['安装工','检测工','维修工'],
				index: 0,
				userinfo: {},
				value: '', //搜索关键词
				installList: [], //安装列表
				dosearch: false,
				showAcount: false,
				page: 1,
				villageList: [],
				active: 0,
				token: '',
				options: [{
						value: 1,
						label: '场站设备'
					},
					{
						value: 2,
						label: '管网设备'
					},
					{
						value: 3,
						label: '公司设备'
					}
				],
				type: false,
				time: false,
				screen: false,
				checkEquipment: {},
				statusList: [],
				screenList: [{
						value: '',
						label: '全部'
					},
					{
						value: 1,
						label: '未检查'
					}, {
						value: 2,
						label: '进行中'
					}, {
						value: 3,
						label: '已提交'
					}, {
						value: 4,
						label: '已审核'
					}
				],
				classifyObj: {},
				statusObj: {}
			};
		},
		onShow() {},
		onLoad() {
			this.checkEquipment = this.options[0]
			this.getInstallDetail()
			this.alltasklist()
		},
		onReachBottom() {
			this.page++
			this.getInstallDetail()
		},
		methods: {
			choose(i) {
				this.checkEquipment = i
				this.page = 1
				this.villageList = []
				this.getInstallDetail()
				this.alltasklist()
			},
			choose_status(i) {
				this.classifyObj = i
				this.page = 1
				this.villageList = []
				this.getInstallDetail()
			},
			choose_screen(i) {
				this.statusObj = i
				this.page = 1
				this.villageList = []
				this.getInstallDetail()
			},
			search() {
				if (this.value) {
					this.page = 1
					this.villageList = []
					this.getInstallDetail()
				}
			},
			downType() {
				this.type = !this.type
				this.time = false
				this.screen = false
			},
			downTime() {
				this.time = !this.time
				this.type = false
				this.screen = false
			},
			downStatus() {
				this.screen = !this.screen
				this.time = false
				this.type = false
			},
			mask() {
				this.type = false
				this.time = false
				this.screen = false
			},
			selectOne(option) {
				this.checkEquipment = option
				this.searchIpt = ''
				this.getInstallDetail()
			},
			searNum() {
				if (!this.searchIpt) {
					uni.showToast({
						title: '请输入要搜索的内容',
						icon: 'none'
					})
					return
				}
				this.getInstallDetail()
			},
			alltasklist() {
				let _this = this
				_this.$request.request({
					url: 'staff/alltasklist',
					method: 'GET',
					header: {
						token: uni.getStorageSync('token')
					},
					data: {
						alltype: _this.checkEquipment.value
					}
				}).then(res => {
					if (res.data.code == 1) {
						_this.statusList = res.data.data
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
			look() {
				uni.navigateTo({
					url: '../inspect/look'
				})
			},
			villages(id) {
				uni.navigateTo({
					
					url: '../inspect/village?alltype=' + this.checkEquipment.value + '&listtype=1&task_id=' + id
					// url: '/pagesB/inspect/details?alltype=' + this.checkEquipment.value + '&status=1&id=' + id
					
				})
			},
			//     //     //     ///
			checkIMEI(id, name) {
				uni.navigateTo({
					url: 'IMEICheck3?id=' + id + '&name=' + name
				})
			},
			navClick(i) {
				this.active = i
			},
			searchFocus() {
				this.showAcount = false
			},
			infoClick() {
				this.showAcount = !this.showAcount
			},
			// 跳转至记录页面
			toJiLu() {
				uni.navigateTo({
					url: './jilu'
				})
			},
			// 跳转用户信息页面
			toCaiLiao(id) {
				uni.navigateTo({
					url: '../userinfo/uninstall?id=' + id
				})
			},
			// 获取安装数据
			getInstallDetail() {
				// uni.showLoading({
				// 	title:'查询中'
				// })
				let that = this
				that.$request.request({
					url: '/staff/task_list',
					method: 'POST',
					header: {
						token: uni.getStorageSync('token')
					},
					data: {
						alltype: that.checkEquipment.value,
						reclassifyid: that.classifyObj.id,
						status: that.statusObj.value,
						page: that.page
					}
				}).then(res => {
					if (res.data.code == 1) {
						that.villageList = that.villageList.concat(res.data.data)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
					}
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	.upColor {
		color: #0DBB79;
	}

	.h400 {
		animation: shrink 0.3s forwards;
	}

	.h300 {
		animation: shrinkstatus 0.3s forwards;
	}

	.trion1 {
		transition: 1s;
	}

	@keyframes shrink {
		0% {
			height: 0rpx;
		}

		100% {
			height: 400rpx;
		}
	}

	@keyframes shrinkstatus {
		0% {
			height: 0rpx;
		}

		100% {
			height: 300rpx;
		}
	}

	.mask {
		width: 100%;
		min-height: 100vh;
		background: rgba(0, 0, 0, 0.5);
		position: fixed;
		transition: 1s;
		z-index: 10;

		.scroll {
			height: 0;
			background: #FFFFFF;
			transition: 1s;

			.scroll-item {
				height: 100rpx;
				padding-left: 46rpx;
				display: flex;
				align-items: center;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				border-bottom: 1rpx solid #F3F3F3;
			}
		}
	}

	.content {
		background-color: #F5F5F5;
		min-height: 100vh;
		// padding-bottom: 200rpx;
		// margin-bottom: 150rpx;
		padding-bottom: 140rpx;

		// 搜索框
		.header1 {
			background-color: #003690;

			.down {
				width: 100%;
				padding: 0 24rpx;
				height: 100rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #DDDDDD;

				.ipt {
					height: 56rpx;
					border-radius: 28rpx;
					border: 1rpx solid #FFFFFF;
					background: #FFFFFF;
					display: flex;
					align-items: center;
					justify-content: center;

					.ipt-icon {
						margin: 0 10rpx;
					}
				}

				.flex1 {
					flex: 1;
				}

				.down-item {
					display: flex;
					align-items: center;
					justify-content: center;
					color: #FFFFFF;

					.rotote {
						transform: rotate(180deg);
						transition: 1s;
					}
				}
			}

			.ipt-box {
				display: flex;
				justify-content: space-between;
				align-items: center;
				box-sizing: border-box;
				padding: 0 20rpx;
				width: 480rpx;
				height: 52rpx;
				background-color: #fff;
				border-radius: 24rpx;

				image {
					width: 32rpx;
					height: 32rpx;
				}
			}

			.header1-right {
				display: flex;
				align-items: center;
				font-size: 28rpx;
				color: #E2ECFB;
				width: 316rpx;
			}
		}

		.list {
			width: 702rpx;
			height: 118rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 6rpx rgba(0, 0, 0, 0.16);
			opacity: 1;
			border-radius: 16rpx;
			margin: 20rpx auto;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding-right: 58rpx;

			.left {
				.top {
					display: flex;
					align-items: center;
					padding-top: 16rpx;

					.img {
						width: 8rpx;
						height: 28rpx;
						background: #003690;
						opacity: 1;
						border-radius: 200rpx;
					}

					.title {
						padding-left: 36rpx;
						font-size: 28rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #333333;
						opacity: 1;
					}
				}

				.bottom {
					display: flex;
					align-items: center;
					padding: 16rpx 0 22rpx 36rpx;

					image {
						width: 28rpx;
						height: 28rpx;
					}

					.time {
						padding-left: 10rpx;
						font-size: 24rpx;
						font-family: Source Han Sans SC;
						font-weight: 400;
						color: #777777;
						opacity: 1;
					}
				}
			}

			.right {
				width: 94rpx;
				height: 46rpx;
				border: 2rpx solid #003690;
				opacity: 1;
				border-radius: 16rpx;
				color: #003690;
				text-align: center;
			}
		}
	}

	.header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		height: 80rpx;
		width: 100%;
		background-color: #003690;
		padding: 0 40rpx;

		.ipt-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 20rpx;
			width: 514rpx;
			height: 52rpx;
			background-color: #fff;
			border-radius: 24rpx;

			image {
				width: 32rpx;
				height: 32rpx;
			}
		}

		.header-right {
			display: flex;
			align-items: center;
			font-size: 32rpx;
			color: #E2ECFB;

			image {
				width: 36rpx;
				height: 36rpx;
			}
		}
	}

	.test-code:active {
		background: rgba(69, 82, 202, 0.4);
		color: #fff;
	}

	.plac-class {
		font-size: 32rpx;
		color: #999;
	}

	// nav
	.nav {
		width: 100%;
		height: 80rpx;
		background-color: #fff;

		.nav-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 50%;
			margin: 0 auto;
			line-height: 76rpx;

			span {
				padding: 0 10rpx;
				font-size: 32rpx;
				color: #333;
				border-bottom: 4rpx solid transparent;
			}

			.current {
				color: #003690;
				border-bottom: 4rpx solid #003690;
			}
		}
	}

	// danger
	.village-item {
		position: relative;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		width: 690rpx;
		padding: 20rpx 30rpx;
		background-color: #fff;
		border-radius: 10rpx;
		margin: 20rpx auto 0;
		box-shadow: 0px 3px 4px rgba(0, 30, 57, 0.15);

		.flag {
			position: absolute;
			right: 0;
			top: 0;
			width: 100rpx;
			height: 100rpx;
		}

		.village-item-left {
			flex: 1;

			// display: flex;
			// align-items: center;
			.adress-box {
				display: flex;
				align-items: center;

				.shuxian {
					width: 8rpx;
					height: 28rpx;
					background-color: #003690;
					border-radius: 8rpx;
					margin-right: 20rpx;
				}

				.adress {
					font-size: 32rpx;
					color: #333;
				}

				.navMap {
					padding: 2rpx 10rpx;
					border-radius: 10rpx;
					border: 1rpx solid #003690;
					color: #003690;
					font-size: 24rpx;
					margin-left: 20rpx;
				}
			}

			.time {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #777;
				padding-left: 20rpx;

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 10rpx;
				}
			}

		}

		.village-item-right {
			display: flex;
			align-items: center;
			padding-right: 30rpx;
			position: relative;

			.huhao {
				font-size: 28rpx;
				color: #999;
			}

			image {
				width: 36rpx;
				height: 36rpx;
			}

			.count {
				width: 32rpx;
				height: 20rpx;
				background: rgba(194, 0, 0, 0.7);
				opacity: 0.69;
				border-radius: 20rpx;
				font-size: 16rpx;
				font-family: Source Han Sans SC;
				font-weight: 400;
				text-align: center;
				color: #FFFFFF;
				position: absolute;
				top: 0;
				right: 6rpx;
			}
		}
	}
</style>
